package com.struts.web.corpor.manage.infomanage;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;

import com.base.Constants;
import com.lg.system.CLGAction;
import com.lg.system.MessageBean;
import com.struts.deal.corpor.manage.infomanage.ApplyBoothDeal;

public class ApplyBoothAction extends CLGAction {

	public ActionForward execute(ActionMapping actionMapping,
			ActionForm actionForm,
			HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ApplyBoothForm aWebForm = (ApplyBoothForm)actionForm;
		ActionMessages msgs = new ActionMessages();
		MessageBean messageBean = new MessageBean();
		if(aWebForm.getMethod()!=null && aWebForm.getMethod().equals("apply")){
			messageBean = ApplyBoothDeal.applyBooth(request, response, aWebForm);
			if(messageBean.isResult()==true){
				return actionMapping.findForward("successmessages");
			}else{
				msgs.add("commonMsgs",new ActionMessage(messageBean.getMessage()));
				saveErrors(request,msgs);
				return actionMapping.findForward("fail");
			}
		}else{
			messageBean = ApplyBoothDeal.defaultApplyBooth(request, response, aWebForm);
			if(messageBean.isResult()==true){
				return actionMapping.getInputForward();
			}else{
				msgs.add("commonMsgs",new ActionMessage(messageBean.getMessage()));
				saveErrors(request,msgs);
				return actionMapping.findForward("fail");
			}

		}
	}
}
